package com.mobilous.client.tips;

import java.util.ArrayList;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;

public class Tips extends Composite {
	
	
	ArrayList<String> list = new ArrayList<String>();
	int place=0;
	public Tips(ArrayList<String> tips, final TipInterface self) {
		list=tips;
		final Tips selfPostit=this;
		AbsolutePanel absolutePanel = new AbsolutePanel();
		initWidget(absolutePanel);
		absolutePanel.setSize("250px", "250px");
		
		Image image = new Image("images/postit.png");
		absolutePanel.add(image, 0, 0);
		image.setSize("100%", "100%");
		
		Button buttonClose = new Button("");
		buttonClose.setStyleName("gwt-Button-tipspostit");
		absolutePanel.add(buttonClose, 231,5);
		buttonClose.setSize("15px", "15px");
		
		Button buttonLast = new Button("");
		buttonLast.setStyleName("gwt-Button-tipspostit");
		absolutePanel.add(buttonLast, 8, 204);
		buttonLast.setSize("15px", "15px");
		
		Button buttonNext = new Button("");
		buttonNext.setStyleName("gwt-Button-tipspostit");
		absolutePanel.add(buttonNext, 225, 204);
		buttonNext.setSize("15px", "15px");
		
		Label lblTip = new Label("Tip :");
		lblTip.setStyleName("gwt-Label-tip-header");
		absolutePanel.add(lblTip, 22, 4);
		
		final Label lblTipText = new Label("To see more tips click on next button at the lower right corner of postit");
		absolutePanel.add(lblTipText, 22, 36);
		lblTipText.setSize("207px", "154px");
		lblTipText.setText(list.get(0));
		buttonClose.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				selfPostit.removeFromParent();
				self.showCheckbox();
			}
		});
		
		buttonNext.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				if(place<list.size()-1)place++;
				lblTipText.setText(list.get(place));
			}
		});
		
		buttonLast.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				if(place>0)place--;
				lblTipText.setText(list.get(place));
			}
		});
	}
 


}
